package mybatis.test;

import mybatis.MyBatisUtils;
import mybatis.mapper.StudentMapper;
import mybatis.pojo.Student;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class updateStudents {
    public static void main(String[] args) {
        SqlSession sqlSession = MyBatisUtils.getSession();
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        List<Student> students = studentMapper.findAllStudent();
        for (Student student : students) {
            student.setAge(18);
            studentMapper.updateStudent(student);
        }
        sqlSession.commit();
    }
}
